import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;
//import java.util.concurrent.Semaphore;


public class handleClient extends Thread {

	protected Socket connectionSocket;

	public handleClient(Socket connectionSocket) throws InterruptedException{
		this.connectionSocket = connectionSocket;

	}
	public void run(){
		try{
			BufferedReader in 
			= new BufferedReader(
					new InputStreamReader(
							connectionSocket.getInputStream()));
			PrintWriter out
			= new PrintWriter(
					new OutputStreamWriter(
							connectionSocket.getOutputStream()));

			while(true){

				String str = in.readLine();
				if(str == null){
					break;
				}else{
					System.out.println("Echo:" + str);
					System.out.flush();
					out.println(str);
					out.flush();
					if(str.trim().equals("quit"))
						break;
				}
				run();
			}
			connectionSocket.close();
		}
		catch(Exception e){}
	}

	




}



